<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Common\BaseConfigController;
use App\Http\Controllers\Common\UploadController;
use App\Http\Controllers\Common\VisitRecordController;
use App\Http\Controllers\Miniprograme\ApiController;
use App\Http\Controllers\Car\CarApiController;
use App\Http\Controllers\Pay\PayNotifyController;
use App\Http\Controllers\Common\LocalUploadFileController;
use App\Http\Controllers\Api\ServiceController;
use App\Http\Controllers\Api\TestController;
use App\Http\Controllers\Miniprograme\SubscribeController;
use App\Http\Controllers\Coupon\CouponLogController;
use App\Http\Controllers\Comment\CommentController;
use App\Http\Controllers\SystemManager\LeaseDailyController;
use App\Http\Controllers\SystemManager\ExDrinkController;
use App\Http\Controllers\Plugin\DirectUploadController;
use App\Http\Controllers\Order\OrderController;
use App\Http\Controllers\ConfigController;
use App\Http\Controllers\Car\AutoInsuranceController;
use App\Http\Controllers\User\BlackListController;
use App\Http\Controllers\Car\ActivePriceController;
use App\Http\Controllers\Car\SurchangeController;
use App\Http\Controllers\Car\InsureController;
use App\Http\Controllers\Car\CostController;
use App\Http\Controllers\Car\ExternalTransferController;
use App\Http\Controllers\Order\EntrymanageController;
use App\Http\Controllers\Car\CarController;
use App\Http\Controllers\Car\MortgageController;
use App\Http\Controllers\Market\MarketExpenseController;
use App\Http\Controllers\Statistics\IncomeController;
use App\Http\Controllers\Wx\WechatController;
use App\Http\Controllers\Car\RetentionController;
use App\Http\Controllers\Car\ExistingEvidenceController;
use App\Http\Controllers\Car\CarUsedController;
use App\Http\Controllers\Car\ReimburseController;
use App\Http\Controllers\Contract\CreateFlowsByTemplatesController;
use App\Http\Controllers\Contract\FlowController;

//图片直传
Route::prefix('direct_upload')->group(function(){
    Route::post('upload_app_token', [DirectUploadController::class,'getAppToken']);
    Route::post('upload_web_token', [DirectUploadController::class,'getWebToken']);
    Route::post('call_back', [DirectUploadController::class,'callback']);
});
//图片上传
Route::prefix('upload')->group(function(){
    Route::post('single',[UploadController::class,'upload']);
    Route::post('multi',[UploadController::class,'multiImgs']);
    Route::post('local',[LocalUploadFileController::class,'upload']);
});
Route::post('visit/inter',[VisitRecordController::class,'inter']);
Route::post('visit/leave',[VisitRecordController::class,'leave']);
//访问记录
Route::prefix('visit')->middleware('auth:sanctum')->group(function(){
    Route::post('index',[VisitRecordController::class,'index']);
});
//小程序用户
Route::prefix('v3/miniprograme')->group(function(){
    Route::post('sessionKey',[ApiController::class,'sessionKey']);
    Route::post('authLogin',[ApiController::class,'authLogin']);
    Route::post('memberInfo',[ApiController::class,'memberInfo']);
    Route::post('update',[ApiController::class,'update']);
});
//基础配置
Route::prefix('v3/config')->group(function(){
    Route::post('list',[BaseConfigController::class,'index']);
    // 公共配置-1
    Route::post('common/list',[ConfigController::class,'list']);
    Route::post('common/store',[ConfigController::class,'store']);
    Route::post('common/update',[ConfigController::class,'update']);
    Route::post('common/edit',[ConfigController::class,'edit']);
    Route::post('common/delete',[ConfigController::class,'destory']);
});
// 记录报错日志
Route::prefix('v3/systemlog')->group(function(){
    // 添加报错日志
    Route::post('add',[ConfigController::class,'addsystemlog']);
});
//用户
Route::prefix('v3/user')->group(function(){
//    Route::post('list',[BaseConfigController::class,'index']);
    // 黑名单
    Route::post('blacklist/list',[BlackListController::class,'list']);
    Route::post('blacklist/store',[BlackListController::class,'store']);
    Route::post('blacklist/update',[BlackListController::class,'update']);
    Route::post('blacklist/edit',[BlackListController::class,'edit']);
    Route::post('blacklist/delete',[BlackListController::class,'destory']);
});
//微信支付通知
Route::prefix('pay')->group(function(){
    Route::any('notify',[PayNotifyController::class,'webWxPay']);
    Route::any('web_wx_notify',[PayNotifyController::class,'webWxPay']);
    Route::any('refund',[PayNotifyController::class,'refundNotify']);
    // 商户打款回调
    Route::any('web_shop_pay',[PayNotifyController::class,'webShopPay']);
});
//车型列表
Route::prefix('car')->group(function(){
    Route::post('getList',[CarApiController::class,'getList']);
    Route::post('getDetail',[CarApiController::class,'getDetail']);
    // 更新车系租车日历
    Route::post('update_car_date',[CarApiController::class,'updateCarDate']);
});


//基础配置
Route::prefix('v3/service')->group(function(){
    Route::post('list',[ServiceController::class,'list']);
    Route::post('category',[ServiceController::class,'category']);
    Route::post('test',[TestController::class,'test']);
});
//订阅消息

Route::prefix('subscribe')->group(function(){
    Route::post('send',[SubscribeController::class,'send_template']);
    Route::get('list',[SubscribeController::class,'template_list']);
});
Route::prefix('v3/coupon')->group(function(){
    Route::post('get',[CouponLogController::class,'get']);
    Route::post('list',[CouponLogController::class,'list']);
    // 获取优惠券-自动
    Route::post('get_new_coupon',[CouponLogController::class,'getCouponUpdate']);
    // 获取优惠券-手动领取
    Route::post('get_coupon_hand',[CouponLogController::class,'getCouponHand']);

});
Route::prefix('comment')->group(function(){
    Route::post('list',[CommentController::class,'list']);
    Route::post('add',[CommentController::class,'add']);
    Route::post('update',[CommentController::class,'update']);
    Route::post('show',[CommentController::class,'show']);
});
Route::prefix('v3/rate')->group(function(){
    Route::post('list',[LeaseDailyController::class,'list']);
});
Route::prefix('v3/order')->group(function(){
    Route::post('lease_change_log',[OrderController::class,'orderChangeLog']);
    //预付信息
    Route::post('pre_paid_info',[OrderController::class,'prepaidInformation']);
});
//随车饮料
Route::prefix('system/drink')->group(function(){
    Route::get('list',[ExDrinkController::class,'list']);
});
//订单
Route::prefix('order')->group(function(){

    Route::post('update',[OrderController::class,'update']);
    Route::post('all',[OrderController::class,'all']);
    Route::post('detail',[OrderController::class,'orderDetail']);
    Route::post('detail_by_id',[OrderController::class,'orderDetailById']);

    Route::post('testTemplate',[OrderController::class,'testTemplate']);


});
Route::prefix('orc')->group(function(){
    Route::post('image',[AutoInsuranceController::class,'index']);
});
// 车辆管理
Route::prefix('v3/car')->group(function(){
    Route::post('active_config/index',[ActivePriceController::class,'index']);
    Route::post('active_config/store',[ActivePriceController::class,'store']);
    Route::post('active_config/update',[ActivePriceController::class,'update']);
    Route::post('active_config/delete',[ActivePriceController::class,'destory']);

    Route::post('surchange_config/index',[SurchangeController::class,'index']);
    Route::post('surchange_config/store',[SurchangeController::class,'store']);
    Route::post('surchange_config/update',[SurchangeController::class,'update']);
    Route::post('surchange_config/delete',[SurchangeController::class,'destory']);

    // 在租车辆
    Route::post('lease_car',[CarController::class,'leaseCar']);
    // 车辆排期表
    Route::post('scheduling',[CarController::class,'scheduling']);
    // 所有车牌号
    Route::post('all_plate_number',[CarController::class,'getAllPlateNumber']);

});
// 车辆保险及车辆费用
Route::prefix('v3/insure')->group(function(){
    Route::post('company/index',[InsureController::class,'index']);
    Route::post('company/store',[InsureController::class,'store']);
    Route::post('company/update',[InsureController::class,'update']);
    Route::post('company/delete',[InsureController::class,'destory']);
    Route::post('company/list',[InsureController::class,'companyList']);
    Route::post('cost/index',[CostController::class,'index']);
    Route::post('cost/all',[CostController::class,'all']);
    Route::post('cost/store',[CostController::class,'store']);
    Route::post('cost/update',[CostController::class,'update']);
    Route::post('cost/delete',[CostController::class,'destory']);
    Route::post('cost/xiufu',[CostController::class,'xiufu']);
});
// 车辆外调
Route::prefix('v3/transfer')->group(function(){
    Route::post('index',[ExternalTransferController::class,'index']);
    Route::post('store',[ExternalTransferController::class,'store']);
    Route::post('edit',[ExternalTransferController::class,'edit']);
    Route::post('update',[ExternalTransferController::class,'update']);
    Route::post('delete',[ExternalTransferController::class,'destory']);
    // 统计
    Route::post('total',[ExternalTransferController::class,'getTotal']);

});
// 入账管理
Route::prefix('v3/entry')->group(function(){
    Route::post('index',[EntrymanageController::class,'index']);
    Route::post('store',[EntrymanageController::class,'store']);
    Route::post('edit',[EntrymanageController::class,'edit']);
    Route::post('update',[EntrymanageController::class,'update']);
    Route::post('delete',[EntrymanageController::class,'destory']);
    Route::post('confirm_rz',[EntrymanageController::class,'confirmRz']);

});
// 车辆外调
Route::prefix('v3/statistics')->group(function(){
    // 批量获取订单结算金额
    Route::post('get_orders_sett',[IncomeController::class,'getOrderSett']);
    // 获取收入统计
    Route::post('get_income',[IncomeController::class,'getIncome']);
    // 获取收入统计--月账单
    Route::post('get_income_month',[IncomeController::class,'getIncomeMonth']);
    // 获取刮擦收入
    Route::post('get_scratch',[IncomeController::class,'getScratch']);
//    事故维修
    Route::post('accendent',[IncomeController::class,'accendent']);
    Route::post('pay_service',[IncomeController::class,'payService']);
//    违章支出
    Route::post('illegals',[IncomeController::class,'illegals']);
    // 出勤统计
    Route::post('attendance',[IncomeController::class,'attendance']);
    // 保养统计
    Route::post('maintenance',[IncomeController::class,'maintenance']);
    // 保险统计
    Route::post('insure',[IncomeController::class,'insure']);
    // 利息统计
    Route::post('interest',[IncomeController::class,'interest']);
    // 营销统计
    Route::post('market_expense',[IncomeController::class,'markerExpense']);
//    残值统计
    Route::post('residual_value',[IncomeController::class,'residualValue']);
//    车辆出租率
    Route::post('attendance',[IncomeController::class,'attendance']);
    // 新增统计
    Route::post('user_add_statistic',[IncomeController::class,'userAddStatistics']);
    // 车辆变更统计
    Route::post('change_order_log',[IncomeController::class,'changeOrderLog']);
    // 订单统计
    Route::post('order_statistics',[IncomeController::class,'orderStaticstics']);
    // 营收统计
    Route::post('revenue_statement',[IncomeController::class,'OrderRevenueStatement']);
    // 手动同步营收信息
    Route::post('revenue_statement_async',[IncomeController::class,'asyncRevenueStatement']);
    // 获取车系名称和车牌号
    Route::post('select_name',[IncomeController::class,'getSelectCarName']);


});
Route::prefix('main')->group(function() {
    Route::any('wechat/token',[\App\Http\Controllers\Wx\WechatController::class,'serve']);
    Route::any('bindUser',[\App\Http\Controllers\Wx\GetUserController::class,'bindUser']);

});
// 获取管理员openid
Route::prefix('v3/manager')->group(function() {
    Route::any('get_openid',[WechatController::class,'getOpenid']);
    Route::any('bind_manager',[WechatController::class,'bindManager']);
});
// 模板消息
Route::prefix('v3/template')->group(function() {
    Route::any('list',[\App\Http\Controllers\Wx\WechatController::class,'templateList']);
    Route::any('send_template',[\App\Http\Controllers\Wx\WechatController::class,'sendTemplate']);
    Route::any('send_template_wx_admin',[\App\Http\Controllers\Wx\WechatController::class,'sendTemplateWxAdmin']);
//    Route::any('bindUser',[\App\Http\Controllers\Wx\GetUserController::class,'bindUser']);

});
//市场营销
Route::prefix('v3/market_expense')->group(function() {
    Route::any('list',[MarketExpenseController::class,'index']);
    Route::any('store',[MarketExpenseController::class,'store']);
    Route::any('update',[MarketExpenseController::class,'update']);
    Route::any('delete',[MarketExpenseController::class,'destory']);

});
// 按揭
Route::prefix('v3/car/mortgage')->group(function() {
    Route::post('list',[MortgageController::class,'index']);
    Route::post('detail',[MortgageController::class,'detail']);
    Route::post('store',[MortgageController::class,'store']);
    Route::post('update',[MortgageController::class,'update']);
    Route::post('delete',[MortgageController::class,'destory']);
    Route::post('repayment_single',[MortgageController::class,'repaymentSingle']);
    Route::post('repayment_batch',[MortgageController::class,'repaymentBatch']);
    Route::post('is_auth_mortgage',[MortgageController::class,'isAuthMortgate']);
    Route::post('update_mark',[MortgageController::class,'updateMark']);
    Route::post('remaining_settlement',[MortgageController::class,'RemainingSettlement']);
    Route::post('get_batch_list',[MortgageController::class,'getBatchList']);
});
// 收入统计
//Route::prefix('v3/static/income')->group(function() {
//    // 租金收入
//    Route::post('rental',[MortgageController::class,'index']);
//
//});
// 数据留存
Route::prefix('v3/retention')->group(function() {
    Route::post('index',[RetentionController::class,'index']);
    Route::post('store',[RetentionController::class,'store']);
    Route::post('edit',[RetentionController::class,'edit']);
    Route::post('update',[RetentionController::class,'update']);
    Route::post('delete',[RetentionController::class,'destory']);
});
// 存证记录
Route::prefix('v3/existing_evidence')->group(function() {
    Route::post('index',[ExistingEvidenceController::class,'index']);
    Route::post('total',[ExistingEvidenceController::class,'total']);
    Route::post('store',[ExistingEvidenceController::class,'store']);
    Route::post('edit',[ExistingEvidenceController::class,'edit']);
    Route::post('update',[ExistingEvidenceController::class,'update']);
    Route::post('delete',[ExistingEvidenceController::class,'destory']);
});
// 精选二手车
Route::prefix('v3/car_used')->group(function() {
    Route::post('index',[CarUsedController::class,'index']);
    Route::post('store',[CarUsedController::class,'store']);
    Route::post('edit',[CarUsedController::class,'edit']);
    Route::post('update',[CarUsedController::class,'update']);
    Route::post('delete',[CarUsedController::class,'destory']);
});
// 车辆报销相关接口
Route::prefix('v3/reimburse')->middleware('auth:sanctum')->group(function() {
    Route::post('index',[ReimburseController::class,'index']);
    Route::post('store',[ReimburseController::class,'store']);
    Route::post('store_month',[ReimburseController::class,'storeMonth']);
    Route::post('edit',[ReimburseController::class,'edit']);
    Route::post('update',[ReimburseController::class,'update']);
    Route::post('update_month',[ReimburseController::class,'updateMonth']);
    Route::post('delete',[ReimburseController::class,'destory']);
    Route::post('examine',[ReimburseController::class,'examine']); // 报销审核
    Route::post('totals',[ReimburseController::class,'totals']); // 报销汇总
});

// 合同
Route::prefix('contract')->middleware('auth:sanctum')->group(function() {
    Route::post('create/by/template',[CreateFlowsByTemplatesController::class,'createFlowsByTemplates']);
    // Route::post('detail/info',[FlowController::class,'flowDetailInfo']);
    Route::post('flow/info/by/order',[FlowController::class,'getFlowInfoByOrder']);
    Route::post('file/upload/component',[\App\Http\Controllers\Contract\ContractFileController::class,'uploadComponentFile']);
    // Route::post('sign/url',[FlowController::class,'getSignUrl']);
    // Route::post('download/url',[FlowController::class,'getDownloadUrl']);
    Route::post('cancel',[FlowController::class,'cancelFlow']);
    Route::post('deleted',[FlowController::class,'deleteFlow']);
});
Route::prefix('contract')->group(function() {
    Route::post('sign/url',[FlowController::class,'getSignUrl']);
    Route::post('download/url',[FlowController::class,'getDownloadUrl']);
    Route::post('detail/info',[FlowController::class,'flowDetailInfo']);
    Route::post('web/url',[FlowController::class,'embedWebUrl']);
});
Route::post('contract/template/info',[\App\Http\Controllers\Contract\ContractTemplateController::class,'templateInfo']);
Route::any('contract/callback',[\App\Http\Controllers\Contract\ContractCallbackController::class,'contractCallback']);
